package model

import (
	"gorm.io/gorm"
	__ "petCombo-srv/proto"
)

type Pets struct {
	gorm.Model
	Name                   string `gorm:"type:varchar(10)" json:"name"`
	Gender                 int    `gorm:"type:int" json:"gender"`
	PetId                  string `gorm:"type:varchar(10)" json:"pet"`
	SterilizationSituation int    `gorm:"type:int" json:"sterilizationSituation"`
	VaccineSituation       int    `gorm:"type:int" json:"vaccineSituation"`
	DewormingSituation     int    `gorm:"type:int" json:"dewormingSituation"`
}

func (p *Pets) PetList(db *gorm.DB, petId int) []*__.PetList {
	var pets []*__.PetList

	query := db.Model(p)

	if petId != 0 {
		query = query.Where("id = ?", petId)
	}

	err := query.Find(&pets).Error
	if err != nil {
		panic(err)
	}
	return pets
}
func (p *Pets) PetAdd(db *gorm.DB) error {
	return db.Create(&p).Error
}
